//
//  HomeViewController.m
//  VistorDemo
//
//  Created by Jack on 2021/8/9.
//

#import "HomeViewController.h"
#import "JKUserManager.h"
#import "JKLoginViewController.h"
#import "JKListViewController.h"
#import "JKVisterChecker.h"

@interface HomeViewController ()
@property (weak, nonatomic) IBOutlet UIButton *loginButton;

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}


- (IBAction)loginAction:(id)sender {
    JKUser *user = [[JKUserManager sharedUserManager] currentUser];
    if (user) {
        //退出登陆
        [[JKUserManager sharedUserManager] signout];
        [self.loginButton setTitle:@"login" forState:(UIControlStateNormal)];
    }else{
        //登陆
        JKLoginViewController *vc = [[JKLoginViewController alloc] init];
        vc.loginCallback = ^(BOOL loginSuccess) {
            [self.loginButton setTitle:@"signout" forState:(UIControlStateNormal)];
        };
        [self presentViewController:vc animated:YES completion:NULL];
    }
}

- (IBAction)orderListAction:(id)sender {
    [JKVisterChecker addToDoThingsAfterLogin:^{
        JKListViewController *vc = [[JKListViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }];
}

- (void)dealloc{
    NSLog(@"home dealloc");
}


@end
